//
//  WSSureOrderSectionHeader.m
//  FD
//
//  Created by xiaofang wang on 2018/11/21.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "WSSureOrderSectionHeader.h"

@interface WSSureOrderSectionHeader()
/**1.标题*/
@property (nonatomic, strong) UILabel *nameLb;
/**2.金额 ￥38 x1 */
@property (nonatomic, strong) UILabel *priceLb;
/**2019-1-3灰色的线 0xf6f6f6*/
@property (nonatomic, strong) UIView *lightgrayLineView;
@end


@implementation WSSureOrderSectionHeader

#pragma mark - 一 init
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.nameLb];
    [self.contentView addSubview:self.priceLb];
    
    //灰色的线 1px
    [self.contentView addSubview:self.lightgrayLineView];
}


#pragma mark - 二 getter
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
        _nameLb.text = @"经典意大利面";
    }
    return _nameLb;
}
- (UILabel *)priceLb {
    if (!_priceLb) {
        _priceLb = [UILabel new];
        _priceLb.text = @"￥38 x1";
        _priceLb.textAlignment = NSTextAlignmentRight;
    }
    return _priceLb;
}
//线
- (UIView *)lightgrayLineView {
    if (!_lightgrayLineView) {
        _lightgrayLineView = [[UIView alloc] init];
        _lightgrayLineView.backgroundColor = [UIColor rb_colorHex:0xf6f6f6];
    }
    return _lightgrayLineView;
}

#pragma mark - 三 layout
- (void)layoutSubviews  {
    [super layoutSubviews];
    
    CGFloat k15 = 15;
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(k15);
        make.top.bottom.equalTo(self.contentView);
        make.right.equalTo(self.priceLb.mas_left);
    }];
    
    //价格
    [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(100, 20));
        make.right.equalTo(self.contentView.mas_right).offset(-k15);
    }];
    
    //线
    [self.lightgrayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.contentView.mas_bottom);
    }];
}

#pragma mark - 赋值
- (void)setModel:(NewCanPinMsgBigModel *)model {
    _model = model;
    self.nameLb.text = model.bigTitle;
    
    //€  shift + alt + 2 €
    //中间有空格
    self.priceLb.text = [NSString stringWithFormat:@"€ %.1f  x%@",model.price, model.quantity];
}

@end
